<?php

class BrandController extends CommonController{
	
	private $_model;
	
	public function __init(){
		
		$this->_model=K('brand');
	}
	
	public function index(){
		
		
		$data=$this->_model->get_all_data();
		
		$this->assign('data',$data);
		
		$this->display();
	}
	
	public function add(){
		
		if(IS_POST){
			if(!$this->_model->add_data()) $this->error($this->_model->error);
			$this->success('添加成功');
		}
		
		$this->display();
	}
	
	public function edit(){
		
		$where=array('bid'=>Q('get.bid'));
		if(IS_POST){
			if(!$this->_model->edit_data($where)) $this->error($this->_model->error);
			
			$this->success('修改成功');
		}
		
		$data=$this->_model->get_one_data($where);
		
		$this->assign('data',$data);
		
		$this->display();
	}
	
	public function del(){
		
		$this->_model->delete_data(array('bid'=>Q('get.bid')));
		$this->success('删除成功');
		
	}
	
	
	
	
}
